package com.yunyao.common.dto.audit;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * @author xingjishuai
 * @date 2024-08-06
 */
@Getter
public enum AuditResultEnums {
    FINISH("finish_", "结束"),
    END("end_", "结束"),
    REJECT("reject_", "驳回"),
    STOP("stop_", "终止"),
    DISAGREE("disagree_", "拒绝"),
    AGREE("agree_", "同意");
    private String key;
    private String msg;

    AuditResultEnums(String key, String msg) {
        this.key = key;
        this.msg = msg;
    }

    public static AuditResultEnums getByKey(String key) {
        for (AuditResultEnums value : AuditResultEnums.values()) {
            if (value.getKey().equals(key)) {
                return value;
            }
        }
        return null;
    }

    public static String getMsgByKey(String key) {
        AuditResultEnums resultEnums = getByKey(key);
        if (Objects.isNull(resultEnums)) {
            return StringUtils.EMPTY;
        }
        return resultEnums.getMsg();
    }

}
